#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int max_i_up_shift = 0, max_i_down_shift = 0, max_j_left_shift = 0, max_j_right_shift = 0;
    int i_shift = 0, j_shift = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (i + max_i_down_shift < n && i + max_i_up_shift >= 0 && j + max_j_right_shift < m &&  j + max_j_left_shift >= 0) {
                cout << i + i_shift + 1 << " " << j + j_shift + 1 << endl << flush;
                string str;
                cin >> str;
                if (str == "L")
                    j_shift--;
                else if (str == "R")
                    j_shift++;
                else if (str == "U")
                    i_shift--;
                else if (str == "D")
                    i_shift++;
                else
                    return 0;
                max_i_up_shift = min(max_i_up_shift, i_shift);
                max_i_down_shift = max(max_i_down_shift, i_shift);
                max_j_left_shift = min(max_j_left_shift, j_shift);
                max_j_right_shift = max(max_j_right_shift, j_shift);
            }
        }
    }

    return 0;
}
